package cn.itcast.activiti.servlet.processinstance;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.RuntimeService;

import cn.itcast.activiti.common.ProcessEngineUtils;

/**
 * 删除流程实例
 * @author Administrator
 *
 */
@WebServlet("/deleteProcessInstance.action")
public class DeleteProcessInstanceServlet extends HttpServlet{

	private static final long serialVersionUID = 5499904700549817131L;
	
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		//获取流程实例Id
		String piId=request.getParameter("piId");
		//获取流程定义Id
		String pdId=request.getParameter("pdId");
		//获取流程引擎
		ProcessEngine processEngine=ProcessEngineUtils.getProcessEngine();
		//获取运行时服务
		RuntimeService runtimeService=processEngine.getRuntimeService();
		runtimeService.deleteProcessInstance(piId, "要你管");
		
		response.sendRedirect(request.getContextPath()+"/queryProcessInstanceByPdId.action?pdId="+pdId);
		
		
	}
	

}
